# coding:utf-8

from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField, SubmitField, BooleanField
from wtforms.validators import DataRequired, Optional
from .constant import IncrementPackType
from ..forms import SelectField


class PackSetForm(FlaskForm):
    """
    created by chenhj at 2017/8/24

    """
    name = StringField('套餐名', validators=[DataRequired()])
    ori_price = StringField('原价', validators=[Optional()])
    price = StringField('价格', validators=[DataRequired()])
    bid_point = IntegerField('汇币', validators=[DataRequired()])
    days = IntegerField('套餐有效日', validators=[DataRequired()])
    tag = StringField('标签', validators=[Optional()])
    submit = SubmitField('保存')


class IncrementPackSetForm(FlaskForm):
    """
    汇币购买的增值套餐（派单点+新项目提醒）
    """
    name = StringField('套餐名', validators=[DataRequired()])
    type = SelectField(
        '套餐类型', coerce=int,
        choices=IncrementPackType.to_options(),
        validators=[Optional()])
    days = IntegerField('套餐有效日', default=31, validators=[Optional()])
    not_limit = BooleanField('是否不限量', default=False, validators=[Optional()])
    bid_point = IntegerField('消耗汇币数', validators=[DataRequired()])
    ori_bid_point = IntegerField('原消耗汇币数', validators=[DataRequired()])
    tag = StringField('标签', validators=[Optional()])
    submit = SubmitField('保存')


class PricePackSetForm(FlaskForm):
    """
    金钱购买的汇币套餐
    """
    name = StringField('套餐名', validators=[DataRequired()])
    ori_price = StringField('原价', validators=[DataRequired()])
    price = StringField('价格', validators=[DataRequired()])
    bid_point = IntegerField('汇币数', validators=[DataRequired()])
    gift_bid_point = IntegerField('赠送汇币数', validators=[Optional()], default=0)
    tag = StringField('标签', validators=[Optional()])
    submit = SubmitField('保存')
